package scalapackage.testspark

import scala.collection.mutable.ArrayBuffer
import org.apache.spark.util.collection.CompactBuffer

/**
  * Created by Germmy on 2018/5/12.
  */
object TestGroupBy2 {
  def main(args: Array[String]) {

   val ab=ArrayBuffer(
      ("h5.learn.com", ArrayBuffer(("h5.learn.com", "http://h5.learn.com/h5/course.shtml", 3), ("h5.learn.com", "http://h5.learn.com/h5/teacher.shtml", 2))),
      ("bigdata.learn.com", ArrayBuffer(("bigdatalearn.com", "http://bigdatalearn.com/bigdata/teacher.shtml", 2))),
      ("ui.learn.com", ArrayBuffer(("ui.learn.com", "http://ui.learn.com/ui/course.shtml", 1), ("ui.learn.com", "http://ui.learn.com/ui/video.shtml", 1), ("ui.learn.com", "http://ui.learn.com/ui/teacher.shtml", 1))),
      ("java.learn.com", ArrayBuffer(("java.learn.com", "http://java.learn.com/java/video.shtml", 3))),
      ("bigdata.learn.com", ArrayBuffer(("bigdata.learn.com", "http://bigdata.learn.com/bigdata/video.shtml", 1), ("bigdata.learn.com", "http://bigdata.learn.com/bigdata/teacher.shtml", 2)))
    )

    //用下groupBy,看下会出现什么效果
    val groupByed: Map[String, ArrayBuffer[(String, ArrayBuffer[(String, String, Int)])]] = ab.groupBy(_._1)

    println(groupByed.toBuffer)


  }

}
